﻿using AnDongBoard.Service;
using Leeder.Business;
using NewAndong.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AnDongBoard.Business
{
    /// <summary>
    /// 
    /// </summary>
    public class PlanMonitorBLL : BaseBLL<PlanMonitorModel, PlanMonitorService>
    {
        public PlanMonitorBLL()
        {
            Service = new PlanMonitorService();
        }

        /// <summary>
        /// 获取一个进度异常
        /// </summary>
        /// <param name="workName">出发链部品名称</param>
        /// <param name="unpackingName">出发链分组名称</param>
        /// <returns></returns>
        public PlanMonitorModel GetModel(string workName,string unpackingName)
        {
            try
            {
                var list = Service.Query(x => x.ProductName == workName && x.AreaName== unpackingName && (x.WorkEndTime == null||x.WorkEndTime==x.WorkStartTime)).ActivedObj.OrderByDescending(x => x.CreateTime).ToList();
                if (list != null && list.Count > 0)
                {
                    return list[0];
                }
                else
                {
                    return default;
                }
            }
            catch (Exception ex)
            {
                LogObj.Error($"67456->{ex.ToString()}");
                return default;
            }
        }

    }
}
